package com.fsc;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;


@Slf4j
@SpringBootApplication(scanBasePackages = {"com.fsc"})
@MapperScan("com.fsc.mapper")
@EnableCaching
@ServletComponentScan
public class StartApplication {

    public static void main(String[] args) throws UnknownHostException {

    SpringApplication app=new SpringApplication(StartApplication.class);
    ConfigurableApplicationContext application=app.run(args);
    //以下内容是直接在控制台输出文档路径
    Environment env = application.getEnvironment();
		log.info("""
      
						----------------------------------------------------------
						应用 '{}' 正在运行! 局域网或本地访问地址如下:
						外部路径:  http://{}:{}
						本地路径:  http://localhost:{}
						----------------------------------------------------------
						"""
				, env.getProperty("spring.application.name")
				, InetAddress.getLocalHost().getHostAddress()
				, env.getProperty("server.port")
				, env.getProperty("server.port")
		);
}
}
